﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


namespace HZ.Supervise.Web.Secondphase.ReportHospitalPurchase
{
    public partial class PurchaseOrderList : BasePage
    {
        HZ.Supervise.IBLL.IBLL_Purchase ibllPurchase = HZ.Supervise.BLLFactory.IBLL_Purchase();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                setBind();
            }
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void setBind()
        {
            string where = "";
            if (!string.IsNullOrEmpty(txtGoodsId.Text.Trim()))
            {

                where += "and GoodsID='" + txtGoodsId.Text.Trim() + "'";
            }
            //中文按Produtname查询，英文按照PinyinCode查询
            if (!string.IsNullOrEmpty(this.txtProductName.Text.Trim()))
            {
                if (HZ.Common.zhHansUtil.HaveChineseCode(this.txtProductName.Text.Trim()))
                {
                    where += "and ProductName like '%" + txtProductName.Text.Trim()+"%'";
                }
                else
                {
                    where += "and PinyinCode like '%" + txtProductName.Text.Trim() + "%'";
                }
            }
            if (!string.IsNullOrEmpty(txtProduceCompany_SC.Text.Trim()))
            {
                 where += "and CompanyName_SC like'%" + txtProduceCompany_SC.Text.Trim() + "%'";
            }
            if (!string.IsNullOrEmpty(txtGoodsName.Text.Trim()))
            {
                where += "and GoodsName like'%" + txtGoodsName.Text.Trim() + "%'";
            }
            if (!string.IsNullOrEmpty(txtMedicineModel.Text.Trim()))
            {
                where += "and MedicineModelName like '%" + txtMedicineModel.Text.Trim() + "%'";
            }
            if (!string.IsNullOrEmpty(txtOutLook.Text.Trim()))
            {
                where += "and Outlookc like '%" + txtOutLook.Text.Trim() + "%'";
            }
            if (!string.IsNullOrEmpty(txtUnit.Text.Trim()))
            {
                where += "and Unit like'%" + txtUnit.Text.Trim() + "%'";
            }
            if (HZ.Common.MyValidate.IsNumeric(txtFactor.Text.Trim()))
            {
                where += "and Factor=" + Convert.ToInt32(txtFactor.Text.Trim());
            } 
            where += "order by HospitalTotalCount desc";
          
            int totalCount = 0;
            DataTable dt = ibllPurchase.GetProcureCatalogByID(where, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
            gvwHospitalList.DataSource = dt;
            gvwHospitalList.DataBind();
            AspNetPager1.RecordCount = totalCount;

        }
   

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            setBind();
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
        }
    }
}
